<template>
  <el-button v-if="hasPermission" v-bind="$attrs">
    <slot />
  </el-button>
</template>

<script setup>
import { computed } from 'vue'
import { useAuthStore } from '../../store'

const props = defineProps({
  permission: {
    type: String,
    required: true
  }
})

const store = useAuthStore()

// 检查是否有权限
const hasPermission = computed(() => {
  return store.getters.hasPermission(props.permission)
})
</script>
